<!--  -->
<template>
  <div>
    <addData >
    
  </addData>
  <!--表格数据  -->
  <el-table :data="tableData" border style="width: 100%">
    <el-table-column align="center" type="selection" width="55" />
    <el-table-column align="center" prop="id" label="编号" width="100" />
    <el-table-column align="center" prop="name" label="秒杀时间段名称" />

    <el-table-column label="每日开始时间" align="center">
      <template #default="scope">
        {{
          scope.row.startTime
            ? moment(scope.row.startTime).format("YYYY-MM-DD HH:mm:ss")
            : ""
        }}
      </template>
    </el-table-column>

    <el-table-column label="每日结束时间" align="center">
      <template #default="scope">
        {{
          scope.row.endTime
            ? moment(scope.row.endTime).format("YYYY-MM-DD HH:mm:ss")
            : ""
        }}
      </template>
    </el-table-column>

    <el-table-column align="center" prop="productCount" label="商品数量" />
    <el-table-column align="center" label="操作">
      <template v-slot="{ row }">
        <el-button type="text" @click="goodsList(row.id)">商品列表</el-button>
      </template>
    </el-table-column>
  </el-table>
  </div>
</template>

<script lang="ts" setup>
import Cookies from "js-cookie";
import { reactive, toRefs, ref } from "vue";
import { useRoute } from "vue-router";
import addData from "../../components/addData.vue";
import { selectListApi } from "../../request/api";
import moment from "moment";
import { useRouter } from "vue-router";

const router = useRouter();

const state = reactive<{
  tableData: {}[];
}>({
  tableData: [],
});

const { tableData } = toRefs(state);

const route = useRoute();

let flashPromotionId = route.query.flashPromotionId || [];
selectListApi({ flashPromotionId }).then((res) => {
  if (res.code === 200) {
    tableData.value = res.data;
  }
  console.log(res.data);
});

const goodsList=(id:number)=>{
   router.push({path: '/sms/flashProductRelation',query:{flashPromotionId:flashPromotionId,flashPromotionSessionId:id}});
}
</script>
<style lang="less" scoped></style>
